home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Christina Milan AM to PM
/
Christina Milan - AM to PM.iso
/
christin.dir
/
00014_Script_Rollover Cursor Change
< prev
next >
Wrap
Text File
|
2001-08-09
|
7KB
|
258 lines
-- DESCRIPTION --
on getBehaviorDescription
return"¼
ROLLOVER CURSOR CHANGE"&RETURN&RETURN&"¼
Changes the cursor when the mouse rolls over the current sprite. ¼
Choose one of the pointers included with Director, ¼
or specify two 1-bit 16x16 pixel bitmap members: ¼
one to act as the pointer image, ¼
the other to define the transparent/opaque areas of the cursor."&RETURN&RETURN&"¼
TIPS:"&RETURN&"¼
Place a single pixel at the topRight and bottomLeft of the image itself to ¼
create what is in fact a 17x17 pixel bitmap. ¼
These extra pixels will not appear in the cursor (they will be clipped) ¼
but the mask will align with them. This ensures that the opaque area ¼
surrounds the cursor image correctly."&RETURN&RETURN&"¼
Set the regPoint of the image to define the cursor's hotspot."&RETURN&RETURN&"¼
PARAMETERS:"&RETURN&"¼
* EITHER - Use one of Director's built-in cursors."&RETURN&RETURN&"¼
* OR - Check button to use your own bitmap images."&RETURN&"¼
* Custom Image " &RETURN&"¼
* Custom Mask"&RETURN&RETURN&"¼
To use custom images, ensure that the check button is on."
end getBehaviorDescription
on getBehaviorTooltip me
return "¼
Use with graphic sprites."&RETURN&RETURN&"¼
Modify the cursor when the"&RETURN&"¼
mouse rolls over the sprite."&RETURN&"¼
Use built-in or custom images."
end getBehaviorTooltip
-- PROPERTIES --
property spriteNum
-- author-defined parameters
property myCursorType
property myBuiltInCursor
property myCursorMember
property myCustomCursor
property myCustomMask
-- internal properties
property mySprite
property mySavedCursor
-- EVENT HANDLERS --
on beginSprite me
SetSpriteCursor me
end beginSprite
on endSprite me
mySprite.cursor = mySavedCursor
end endSprite
-- CUSTOM HANDLER --
on SetSpriteCursor me
if spriteNum < 1 then
if the runMode = "Author" then
ErrorAlert me
end if
end if
mySprite = sprite (me.spriteNum)
-- Save cursor to revert to
mySavedCursor = mySprite.cursor
-- Set the cursor of the sprite
if voidP (myCursorType) then
mySprite.cursor = myBuiltInCursor
exit
end if
case myCursorType of
"Built-in cursor":
mySprite.cursor = myBuiltInCursor
"Cursor member":
myCursorMember = value (myCursorMember)
cursorList = [myCursorMember.number]
mySprite.cursor = cursorList
"1 bit bitmap":
myCustomCursor = value (myCustomCursor)
cursorList = [myCustomCursor.number]
if myCustomMask <> "no mask" then
myCustomMask = value (myCustomMask)
cursorList.append(myCustomMask.number)
end if
mySprite.cursor = cursorList
end case
end SetSpriteCursor
-- ERROR CHECKING --
on ErrorAlert me
-- sent by SetSpriteCursor
-- Determine the behavior's name
behaviorName = string (me)
delete word 1 of behaviorName
delete the last word of behaviorName
delete the last word of behaviorName
alert "¼
BEHAVIOR ERROR: Frame "&the frame&", Sprite "&me.spriteNum&RETURN&RETURN&"¼
Behavior "&behaviorName&"has been attached to the frame."&RETURN&RETURN&"¼
It will have no effect, and should be removed from the behavior channel."
end ErrorAlert
-- AUTHOR-DEFINED PARAMETERS --
on getPropertyDescriptionList me
if not the currentSpriteNum then exit
propertyDescriptionList = [:]
cursorTypes = []
cursorMembersList = GetCursorMembers (me)
cursorBitmapsList = GetCursorBitmaps (me)
cursorMasksList = duplicate (cursorBitmapsList)
cursorMasksList.addAt (1, "no mask")
cursorMembers = cursorMembersList.count()
bitmapCursors = cursorBitmapsList.count()
if cursorMembers then
cursorTypes.append ("Cursor member")
end if
if bitmapCursors then
cursorTypes.append ("1 bit bitmap")
end if
if cursorTypes.count() then
cursorTypes.addAt (1, "Built-in cursor")
propertyDescriptionList.addProp ¼
( ¼
#myCursorType, ¼
[¼
#comment: "CHOICE OF TYPE - Use which type of cursor?", ¼
#format: #string, ¼
#range: cursorTypes, ¼
#default: cursorTypes[1]¼
] ¼
)
propertyDescriptionList.addProp ¼
( ¼
#myBuiltInCursor, ¼
[¼
#comment: "CHOICE OF CURSOR - Built-in cursor:", ¼
#format: #cursor, ¼
#default: 280¼
] ¼
)
else
return ¼
[ ¼
#myBuiltInCursor: ¼
[¼
#comment: "Use which cursor?", ¼
#format: #cursor, ¼
#default: 280¼
] ¼
]
end if
if cursorMembers then
propertyDescriptionList.addProp ¼
( ¼
#myCursorMember, ¼
[¼
#comment: "- Cursor member:", ¼
#format: #member, ¼
#range: cursorMembersList, ¼
#default: cursorMembersList[1] ¼
] ¼
)
end if
if bitmapCursors then
propertyDescriptionList.addProp ¼
( ¼
#myCustomCursor, ¼
[ ¼
#comment: "- 1 bit bitmap (image):", ¼
#format: #bitmap, ¼
#range: cursorBitmapsList, ¼
#default: cursorBitmapsList[1]¼
] ¼
)
propertyDescriptionList.addProp ¼
( ¼
#myCustomMask, ¼
[ ¼
#comment: "1 bit bitmap (mask):", ¼
#format: #bitmap, ¼
#range: cursorMasksList, ¼
#default: cursorMasksList[1]¼
] ¼
)
end if
return propertyDescriptionList
end
on GetCursorMembers me
cursorMembersList = []
maxCastLib = the number of castLibs
repeat with theCastLib = 1 to maxCastLib
maxMember = the number of members of castLib theCastLib
repeat with memberNumber = 1 to maxMember
theMember = member(memberNumber, theCastLib)
if theMember.type = #cursor then
if theMember.name = EMPTY then
cursorMembersList.append(theMember)
else
cursorMembersList.append(theMember.name)
end if
end if
end repeat
end repeat
return cursorMembersList
end GetCursorMembers
on GetCursorBitmaps me
cursorBitmapsList = []
maxCastLib = the number of castLibs
repeat with theCastLib = 1 to maxCastLib
maxMember = the number of members of castLib theCastLib
repeat with memberNumber = 1 to maxMember
theMember = member(memberNumber, theCastLib)
if theMember.type = #bitmap then
if theMember.depth > 1 then next repeat
if theMember.width > 20 then next repeat
if theMember.height > 20 then next repeat
if theMember.name = EMPTY then
cursorBitmapsList.append(theMember)
else
cursorBitmapsList.append(theMember.name)
end if
end if
end repeat
end repeat
return cursorBitmapsList
end GetCursorMembers